﻿using System.Collections.ObjectModel;
using NPMonitor.DataModel;
using System.Collections.Generic;

namespace NPMonitor.Interfaces
{
    public interface IMachineStore
    {
        /// <summary>
        /// 获取所有机器
        /// </summary>
        /// <returns></returns>
        ReadOnlyCollection<MachineData> GetAllMachines();

        /// <summary>
        /// 分页获取所有机器
        /// </summary>
        /// <returns></returns>
        ReadOnlyCollection<MachineData> GetAllMachines(int pageIndex, int pageSizes);

        /// <summary>
        /// 获取所有机器的总数
        /// </summary>
        /// <returns></returns>
        int GetAllMachinesTotalCount();

        /// <summary>
        /// 根据机器pool id 获取所有机器
        /// </summary>
        /// <param name="poolId"></param>
        /// <returns></returns>
        ReadOnlyCollection<MachineData> GetMachinesByPoolId(int poolId);

        /// <summary>
        /// 根据机器pool id 分页获取所有机器
        /// </summary>
        /// <param name="poolId"></param>
        /// <returns></returns>
        ReadOnlyCollection<MachineData> GetMachinesByPoolId(int poolId, int pageIndex, int pageSizes);

        /// <summary>
        /// 根据机器pool id 获取所有机器的总数
        /// </summary>
        /// <param name="poolId"></param>
        /// <returns></returns>
        int GetAllMachinesTotalCountByPoolId(int poolId);

        /// <summary>
        /// 获取所有的机器池
        /// </summary>
        /// <returns></returns>
        ReadOnlyCollection<MachinePool> GetAllMachinePool();

        /// <summary>
        /// 获取所有的机器池并进行分页
        /// </summary>
        /// <returns></returns>
        List<MachinePool> GetAllMachinePool(int pageIndex, int pageSizes);

        /// <summary>
        /// 根据机器Id获取机器信息
        /// </summary>
        /// <param name="machineId"></param>
        /// <returns></returns>
        MachineData GetMachineInfoById(int machineId);

        /// <summary>
        /// 根据机器池Id获取池信息
        /// </summary>
        /// <param name="poolId"></param>
        /// <returns></returns>
        MachinePool GetMachinePoolInfoById(int poolId);
        
        /// <summary>
        /// 编辑机器信息
        /// </summary>
        /// <param name="mdInfo"></param>
        /// <returns></returns>
        void EditMachine(MachineData mdInfo);

        /// <summary>
        /// 注册机器到服务器
        /// </summary>
        /// <param name="machineInfo"></param>
        /// <returns></returns>
        bool CheckAndRegisterMachine(MachineInfo machineInfo);
        
        /// <summary>
        /// 根据机器名查找机器状态 
        /// </summary>
        /// <param name="machineName"></param>
        /// <returns></returns>
        MachineData GetMachineByMachineName(string machineName);

        /// <summary>
        /// Heart beating specified machine by machine name
        /// </summary>
        /// <param name="machineName"></param>
        /// <returns>
        /// -1: Can't found machine, need to register machine first
        /// 1: beated successfully
        /// </returns>
        bool Heartbeat(string machineName);

        /// <summary>
        /// Save the mechinePool
        /// </summary>
        /// <param name="PoolId"></param>
        /// <param name="machinePool"></param>
        void SavePoolInfo(int PoolId, MachinePool machinePool);

        /// <summary>
        /// Delete the Pool
        /// </summary>
        /// <param name="PoolId"></param>
        bool DeletePoolById(int PoolId);

        /// <summary>
        /// Check Pool whether exist
        /// </summary>
        /// <returns></returns>
        bool CheckPool(int poolId, string PoolName);

        /// <summary>
        /// get the MachinePool count
        /// </summary>
        /// <returns></returns>
        int GetMachinePoolCount();

        /// <summary>
        /// check Pool whether has machine
        /// </summary>
        /// <param name="poolId"></param>
        /// <returns></returns>
        bool CheckPoolMachine(int poolId);
    }
}
